<%-- 
    Document   : generate
    Created on : Dec 26, 2009, 8:52:51 AM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib  prefix="hex" uri="/WEB-INF/hex.tld" %>
<style type="text/css">
    .selected {
        background: yellow;
    }
</style>

<script type="text/javascript">
    function toggleAll(name, checked){
        var checkboxes = document.getElementsByName(name);
        for (var i=0; i<checkboxes.length; i++){
            checkboxes[i].checked = checked;
        }
    }

    function setAdd(questionAutoId){
        document.getElementsByName("idToAdd").item(0).value = questionAutoId;
    }

    function setRemove(questionAutoId){
        document.getElementsByName("idToRemove").item(0).value = questionAutoId;
    }



</script>

<div style="width: 900px">
    <div style="width: 100%; float: right;">
        <div style="margin-left: 500px;">
            <table border="1">
                <tr>
                    <td colspan="2">
                        <form method="post">
                            <input type="hidden" name="idToRemove"/>
                            <table border="1">
                                <tr>
                                    <th colspan="6">Questions will be used in the test</th>
                                </tr>
                                <tr>
                                    <th></th>
                                    <th>
                                        <input name="checkAll" onclick="toggleAll('idToRemoveMany', this.checked)" type="checkbox" /></th>
                                    <th>No.</th>
                                    <th>Content</th>
                                    <th>Type</th>
                                    <th></th>
                                </tr>
                                <c:forEach var="question" items="${selectedQuestions}" varStatus="counter">
                                    <tr>
                                        <td>
                                            <input name="remove" type="submit" onclick="setRemove(${question.autoId})" value="&lt; Remove" /></td>
                                        <td>
                                            <input name="idToRemoveMany" type="checkbox" value="${question.autoId}" /></td>
                                        <td>${counter.count}</td>
                                        <td>${question.content}</td>
                                        <td>${question.descriptiveType}</td>
                                        <td><a href="#">Preview</a></td>
                                    </tr>
                                </c:forEach>
                                <tr>
                                    <td colspan="6">
                                        <input type="submit" name="removeMany" value="&lt;&lt; Remove all checked" />
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </td>
                </tr>
                <form method="post">
                    <tr>
                        <td>Test name</td>
                        <td>
                            <input name="name" type="text" value="" /></td>
                    </tr>
                    <tr>
                        <td>Number of selected questions</td>
                        <td><strong>${selectedQuestions.size$}</strong></td>
                    </tr>
                    <tr>
                        <td>Number of questions for each test</td>
                        <td><input name="questionsPerTest" type="text" value="${selectedQuestions.size$}" /></td>
                    </tr>
                    <tr>
                        <th colspan="2">Account list</th>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <textarea cols="40" name="accounts" rows="10">${param["accounts"]}</textarea></td>
                    </tr>
                    <tr>
                        <td colspan="2">Accounts from Excel file:
                            <input type="file" /></td>
                    </tr>
                    <tr>
                        <td colspan="2"><input type="submit" name="generate" value="Generate" /></td>
                    </tr>
                </form>
            </table>
        </div>
    </div>
    <div style="float: right; margin-right: -500px; width: 500px;">
        <form method="post">
            <input type="hidden" name="idToAdd"/>
            <table border="1">
                <tr>
                    <td colspan="2">Select a category </td>
                </tr>
                <tr>
                    <td colspan="2">
                        ${hex:getCategoryTreeHTML(category, "?catId=%d")}
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table border="1">
                            <tr>
                                <th colspan="6">Select questions to be used in the test</th>
                            </tr>
                            <tr>
                                <th>
                                    <input name="checkAll" onclick="toggleAll('idToAddMany', this.checked)" type="checkbox" /></th>
                                <th>No.</th>
                                <th>Content</th>
                                <th>Type</th>
                                <th></th>
                                <th></th>
                            </tr>
                            <c:forEach var="question" items="${questions}" varStatus="counter">
                                <tr>
                                    <td>
                                        <input name="idToAddMany" type="checkbox" value="${question.autoId}" /></td>
                                    <td>${counter.count}</td>
                                    <td>${question.content}</td>
                                    <td>${question.descriptiveType}</td>
                                    <td><a href="#">Preview</a></td>
                                    <td><input name="add" type="submit" value="Add&gt;" onclick="setAdd(${question.autoId})"/> </td>
                                </tr>
                            </c:forEach>
                            <tr>
                                <td colspan="6">
                                    <input type="submit" name="addMany" value="Add all checked &gt;&gt;" /></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
